﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GE.Font;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Content;

using GE.Objects;

namespace GE
{
    class GameOverScreen : GameScreen
    {
        private long wave;
        private double playTime;
        private Hero hero;
        private Song song;

        public GameOverScreen(long wave, Hero hero, double playTime)
        {
            this.wave = wave;
            this.hero = hero;
            this.playTime = playTime;
        }

        public override void LoadContent()
        {
            base.LoadContent();

            ContentManager content = new ContentManager(ScreenManager.Game.Services, "Content");

            song = content.Load<Song>("BGM/gameover");
            MediaPlayer.Play(song);
            MediaPlayer.IsRepeating = true;
        }

        double totalTime = 0;
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                                       bool coveredByOtherScreen)
        {
            totalTime += gameTime.ElapsedGameTime.TotalSeconds;
        }

        public override void HandleInput(InputState input)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                MediaPlayer.Stop();
                this.ExitScreen();
                ScreenManager.AddScreen(new longroScreen(), PlayerIndex.One);
            }
        }

        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            spriteBatch.Begin();

            FreetypeFont.DrawString(spriteBatch, "게임 오버 : Wave " + wave,
                new Vector2(100, 100), -0.0f,
                36, Color.White);

            //웨이브 정보
            FreetypeFont.DrawString(spriteBatch, "용사를 레벨 " + hero.Level + "까지 키우셨습니다.",
                new Vector2(100, 150),
                12, Color.White);

            //웨이브 정보
            FreetypeFont.DrawString(spriteBatch, "플레이 타임은 총 " + ((long)playTime) + "초 입니다.",
                new Vector2(100, 180),
                12, Color.White);

            FreetypeFont.DrawString(spriteBatch, "다시 하려면 space키를 누르세요.",
                new Vector2(300, 500), -0.00f, 12, Color.Red);

            spriteBatch.End();
        }
    }
}
